<?php
namespace Entities\Corp;
use Doctrine\ORM\Query;
use Doctrine\ORM\EntityRepository;

class PessoaJuridicaRepository extends EntityRepository
{
	public function listar($params = array())
	{
		$qb		= $this->getEntityManager()->createQueryBuilder();
		$qb->select('p')
		->from('Entities\Corp\PessoaJuridica', 'p');

		$where	= $qb->expr()->andX();
		$where->add($qb->expr()->eq(1,1));
		foreach ($params as $key => $value)
		{
			$where->add($qb->expr()->eq($key, $value));
		}
		$qb->where($where)
		->orderBy('p.dsnome');

		return $this->getEntityManager()->createQuery($qb->getDQL());
	}

	public function listCombo()
	{
		$return	= array();
		foreach ($this->listar()->getResult() as $value)
		{
			$return[$value->get('idpessoa')]	= $value->get('dsapelido');
		}
		return $return;
	}
}